<template>
<div class="app-container">
  <loading v-show="loading"></loading>
  <el-card class="box-card searchFormStyle" style="margin-bottom:1%;">
    <div slot="header" class="clearfix">
      <span>考核指标操作</span>
    </div>
    <div class="text item">
      <el-form ref="searchData" :model="searchData" label-width="130px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="子周期名称">
              <el-input v-model="searchData.quarterAssessmenName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item>
              <el-button type="primary" 
              icon="el-icon-search"
              v-if="permissionHandle('childMemberCircle:getList')"
              @click="getList">查 询</el-button>
              <el-button type="primary" 
              icon="el-icon-refresh"
              v-if="permissionHandle('childMemberCircle:getList')"
              @click="resetSearch">重 置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </el-card>
  <el-card class="box-card" style="margin-bottom:1%;">
    <div slot="header" class="clearfix">
      <span>考核类型列表</span>
    </div>
    <el-table
      :data="tableData"
      border
      ref="tableData"
      style="width: 100%;margin-bottom:1%;"
      >
      <el-table-column
        type="selection"
        width="40">
      </el-table-column>
      <el-table-column
        label="子考核周期名称"
        width="180">
        <template slot-scope="scope">
            {{ scope.row.quarterAssessmenName }}
        </template>
      </el-table-column>
      <el-table-column
        label="父考核周期名称"
      >
        <template slot-scope="scope">
            {{ scope.row.cycleAssessmenKey }}
        </template>
      </el-table-column>
      <el-table-column
        label="考核开始时间"
      >
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.assessmenBeginTime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="考核结束时间"
      >
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.assessmenEndTime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="创建日期"
        width="180"
      >
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="240px">
          <template slot-scope="scope">
            <el-button
              size="mini"
              icon="el-icon-document"
              v-if="permissionHandle('childMemberCircle:comment')"
              @click="selfReported(scope.$index, scope.row)">自查自评</el-button>
            <el-button
              size="mini"
               v-if="permissionHandle('childMemberCircle:Assessment')"
              icon="el-icon-document"
              @click="nextReported(scope.$index, scope.row)">考核</el-button>
          </template>
        </el-table-column>
    </el-table>
    <pagination @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" :paginations="paginations"></pagination>
  </el-card>
</div>
</template>
<script>
import Loading from '@/components/loading/loading'
import pagination from '@/components/pagination/index'
import { getMember } from '@/api/partyMember/childMemberCircle'
export default {
  components: {
    Loading,
    pagination
  },
  data() {
    this.permissionHandle = this.$permissionHandle
    return {
      paginations: {
        totalNum: 0,
        currentPage: 1,
        pageSize: 10
      },
      searchData: {
        quarterAssessmenName: '',
        pageSize: '10',
        pageNum: '1'
      },
      detailData: {
        createTime: '',
        cycleAssessmenKey: '',
        deleteState: '',
        dyIndexHistoryKey: '',
        dyIndexName: '',
        indexTypeKey: '',
        weights: ''
      },
      loading: false,
      tableData: [],
      dialogTitle: '指标详细',
      // 新增角色数据
      addForm: {
        dyIndexHistoryKey: ''
      },
      dialogFormVisible: false, // 新增弹出框状态
      Exam: [],
      ExamType: [],
      detailFormVisible: false
    }
  },
  created() {
    this.getExamList()
  },
  methods: {
    resetSearch() {
      this.searchData.quarterAssessmenName = ''
      this.getExamList()
    },
    getList() {
      this.searchData.pageNum = 1
      this.getExamList()
      this.paginations.currentPage = 1
    },
    // 查询参数
    getExamList() {
      this.loading = true
      return new Promise((resolve, reject) => {
        getMember(this.searchData).then(response => {
          this.tableData = response.data.items
          this.paginations.totalNum = parseInt(response.data.itemsTotalCount)
          this.loading = false
          resolve()
        }).catch(error => {
          this.loading = false
          reject(error)
        })
      })
    },
    selfReported(index, row) {
      this.$router.push({
        path: 'partyMemberSelfReported',
        name: '党员自查自评',
        query: {
          quarterCycleKey: row.quarterCycleKey,
          operationFlag: '001'
        }
      })
    },
    nextReported(index, row) {
      this.$router.push({
        path: 'partyMembernextReportedList',
        name: '党员考核列表',
        query: {
          quarterCycleKey: row.quarterCycleKey
        }
      })
    },
    // 输入参数查询之后
    blurSearch(value) {
      this.getList()
    },
    handleSizeChange(val) {
      this.searchData.pageSize = val
      this.getExamList()
    },
    handleCurrentChange(val) {
      this.searchData.pageNum = val
      this.getExamList()
    }
  }
}
</script>
<style lang="scss">
  .tree-input{
    position: relative;
  }
  .input-tree{
      height:200px;width: 100%;
      .el-scrollbar__wrap{overflow: auto;}
    }
    .detail-col{height:40px;line-height: 40px;}
  .title-span{font-size: 16px;display:inline-block;width:100%;height:40px;line-height:40px;border-bottom:1px solid #e6e6e6}

</style>
